function getCookie(name) {
    var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
    return r ? r[1] : undefined;
}

$(document).ready(function () {
    $("#mobile").focus(function () {
        $("#mobile-err").hide();
    });
    $("#password").focus(function () {
        $("#password-err").hide();
    });
    $(".form-login").submit(function (e) {
        e.preventDefault();
        mobile = $("#mobile").val();
        passwd = $("#password").val();
        if (!mobile) {
            $("#mobile-err span").html("请填写正确的手机号！");
            $("#mobile-err").show();
            return;
        }
        if (!passwd) {
            $("#password-err span").html("请填写密码!");
            $("#password-err").show();
            return;
        }

        var data = {

            "mobile": mobile,
            "pwd": passwd

        };
        data_json = JSON.stringify(data);

        $.ajax({
            url: '/api/v1.0/login',
            type: 'post',
            data: data_json,
            contentType:'application/json',
            dataType:'json',
            success: function (data) {
                alert(data.errmsg);
                if (data.errno == 0) {
                    //登陆成功,跳转到首页
                    location.href = '/index.html';
                } else {
                    location.reload(true);
                }

            }

        })


    });
})